////////////////////////////////////////////////////////////////////////////////
// Copyright 2006 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   ACCESS_RIGHT
// AUTHOR           :   Victor Zheng 
// DATE CREATE      :   2006/02/01
// DESCRIPTION      :   a MAINTENANCE ACTION file for the function, ACCESS_RIGHT
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2006/02/01   Victor Zheng    1.0                 source is generated.
// 2006/06/20   William Xu      1.0                 BugZilla #6277
// 2006/08/28   Jimmy Chen      1.3                 Status should default to ACTIVE
//
//
////////////////////////////////////////////////////////////////////////////////

package com.erp.app.admin.accessRight.web;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.erp.app.admin.accessRight.pk.AccessRightHdrPk;
import com.erp.app.admin.accessRight.schema.AccessRightDtlSchema;
import com.erp.app.admin.accessRight.schema.AccessRightHdrSchema;
import com.erp.app.admin.accessRight.vo.AccessRightHdrVo;
import com.erp.app.common.ProjectConstants;
import com.erp.app.util.web.WebUtil;
import com.erp.framework.controller.action.SimpleMaintStyleAction;
import com.erp.framework.controller.form.MultiRow;
import com.erp.framework.controller.form.SimpleMaintStyleForm;
import com.erp.framework.model.pk.SimpleBasePk;
import com.erp.framework.model.schema.MetaData;
import com.erp.framework.model.schema.TableSchema;
import com.erp.framework.util.BeanUtil;
import com.erp.framework.util.CommonUtil;
import com.erp.framework.util.logger.Logger;
import com.erp.framework.util.user.User;

/**
* A <strong>Maintenance Action</strong> is an adapter between the contents of an incoming
* HTTP request and the corresponding business logic that should be executed to
* process this request.  The controller (ActionServlet) will select an
* appropriate Action for each request.
* The main purpose for this action class is to handle the user document maintenance events
* from the web browsers.
*
* @author          Victor Zheng 
* @version 1.0     2006/02/01
* @since           FrameWork 1.0
*
*/
public class AccessRightMaintenanceAction extends SimpleMaintStyleAction {

	////////////////////////////////////////////////////////////////////////////////
	// CONSTANTS DEFINITION
	////////////////////////////////////////////////////////////////////////////////

	//public static final String ACTION_DO_SOMETHING = "actionDoSomething";
	//public static final String STATUS_DO_SOMETHING = "statusDoSomething";

	public static final int TAB_IDX_DTL = 0;


	////////////////////////////////////////////////////////////////////////////////
	// GLOBAL VARIABLES DEFINITION
	////////////////////////////////////////////////////////////////////////////////



	////////////////////////////////////////////////////////////////////////////////
	// LOGICAL AND BUSINESS METHODS
	////////////////////////////////////////////////////////////////////////////////

	public ActionForward handlePageEvent(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
			if (!isHandled(request) && action.equalsIgnoreCase(ACTION_ADD_DTL)) {
				processActionAddDetail(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_DEL_DTL)) {
				processActionDelDetail(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);			
			}else if(!isHandled(request) && action.startsWith(ACTION_SPEDIT)){
				processActionSpEdit(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			}
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}

	protected ActionForward processOtherStatus(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response,
		ActionErrors errors, String rb_status) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
			if(rb_status.startsWith(STATUS_SPSET)){
				return processStatusSPSet(mapping,  formIn,  request, response,  errors,  rb_status);
			}
//			if (rb_status.equalsIgnoreCase(STATUS_DO_SOMETHING)) {
//				return processStatusDoSomething(mapping,  formIn,  request, response,  errors,  rb_status);
//			}
		} catch (Exception e) {
			Logger.log(this, e);
		}

		return actionForward;
	}

	//uncomment the following code and implement the method if necessary
	/*
	protected ActionForward processActionDoSomething(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try{
			System.out.println("You are in processActionDoSomething().");
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}
	*/

	//uncomment the following code and implement the method if necessary
	/*
	protected ActionForward processStatusDoSomething(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response,
		ActionErrors errors, String rb_status) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try{
			System.out.println("You are in processStatusDoSomething().");
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}
	*/
	
    public ActionForward processActionSpEdit(ActionMapping mapping, ActionForm formIn,
            HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {
        SimpleMaintStyleForm form = (SimpleMaintStyleForm) formIn;
        HttpSession session = request.getSession(false);
        ActionForward actionForward = new ActionForward(mapping.getInput());
        String action = CommonUtil.nullToString(form.getPageEvent());
        session.removeAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS);
        String fieldName = BeanUtil.toPropertyName(form.getPageEvent().substring(ProjectConstants.ACTION_SPEDIT.length()));
        String fieldValue = "";
        String columnName = "";
        String eventSrc = form.getPageEventSrc();
        LinkedList keyList = new LinkedList();
//        processActionSpEditAddHdrLabel(mapping, form, request, response, errors, keyList);
        boolean readonly = form.isReadOnly();
        String fieldObjectId = "";
        Object formOrMultiRow = form;
        TableSchema ts = form.getTs();
        if (CommonUtil.isValidInteger(eventSrc)) {
            formOrMultiRow = WebUtil.getCurrentRow(form);
            readonly |= (((MultiRow) formOrMultiRow).isReadOnly() || ((MultiRow) formOrMultiRow).isDeleted());
            ts = form.getChildTs()[form.getCurrIdx()]; // MaintStyleForm-specific
        }
        MetaData metadata = ts.getMetaDataByVoName(fieldName);
        if (metadata == null) {
            metadata = BeanUtil.getMetaData(form, fieldName);
            if (metadata != null) fieldValue = CommonUtil.nullToString(BeanUtil.getPropertyDefault(form, fieldName));
        } else {
            fieldValue = CommonUtil.nullToString(BeanUtil.getPropertyDefault(formOrMultiRow, fieldName));
        }
        if (metadata == null) {
            Logger.debug(this, "metadata is null: " + fieldName);
            fieldValue = "metadata is null: " + fieldName;
        } else {
            fieldObjectId = metadata.getWebObjectId();
            columnName = metadata.getWebLabelName();
        }
        HashMap params = new HashMap();
        params.put(ProjectConstants.SESSION_SESSION_VALUE, getSessionSimpleMaintStatus());
        params.put(ProjectConstants.SESSION_OPENER_PATH, getFunctionId());
        params.put(ProjectConstants.SESSION_KEY_LIST, keyList);
        if (readonly) params.put(ProjectConstants.SESSION_SIMPLE_READ_ONLY, ProjectConstants.GENERIC_YES);
        params.put(ProjectConstants.SESSION_FIELD, fieldName);
        if (!CommonUtil.isEmpty(eventSrc)) params.put(ProjectConstants.SESSION_EVENTSRC, eventSrc);
        params.put(ProjectConstants.SESSION_EDIT_COLUMN_NAME, columnName);
        params.put(ProjectConstants.SESSION_EDIT_VALUE, fieldValue);
        params.put(ProjectConstants.SESSION_EDIT_COLUMN_OBJECT_ID, fieldObjectId);
        this.setValuesForActionSpEdit(mapping, formIn, request, response, errors, formOrMultiRow, ts, keyList, params);
        session.setAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS, params);
        return actionForward;
    }

    protected void setValuesForActionSpEdit(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response,
    		ActionErrors errors, Object formOrMultiRow, TableSchema ts, LinkedList keyList, HashMap params) {
        params.put(ProjectConstants.SESSION_SIMPLE_HIDE_REMARK_MASTER, ProjectConstants.GENERIC_YES);
        params.put(ProjectConstants.SESSION_SIMPLE_HIDE_REMARK_DETAIL, ProjectConstants.GENERIC_YES);
        params.put(ProjectConstants.SESSION_SIMPLE_HIDE_REMARK_APPEND, ProjectConstants.GENERIC_YES);
    }
    
    public ActionForward processStatusSPSet(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
            HttpServletResponse response, ActionErrors errors, String rb_status) {
        SimpleMaintStyleForm form = (SimpleMaintStyleForm) formIn;
        HttpSession session = request.getSession(false);
        ActionForward actionForward = new ActionForward(mapping.getInput());
        HashMap params = (HashMap) session.getAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS);
        session.removeAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS);
        String editValue = (String) params.get(ProjectConstants.SESSION_EDIT_VALUE);
        String columnName = (String) params.get(ProjectConstants.SESSION_EDIT_COLUMN_NAME);
        String fieldObjectId = (String) params.get(ProjectConstants.SESSION_EDIT_COLUMN_OBJECT_ID);
        String fieldName = (String) params.get(ProjectConstants.SESSION_FIELD);
        String eventSrc = (String) params.get(ProjectConstants.SESSION_EVENTSRC);
        Object formOrMultiRow = form;
        TableSchema ts = form.getTs();
        if (CommonUtil.isValidInteger(eventSrc)) {
            formOrMultiRow = WebUtil.getCurrentRow(form);
            ts = form.getChildTs()[form.getCurrIdx()]; // MaintStyleForm-specific
        }
        BeanUtil.setPropertyDefault(formOrMultiRow, fieldName, editValue);
        return actionForward;
    }
	
	protected ActionForward processActionAddDetail(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try{
			ArrayList rows = form.getMultiRows(TAB_IDX_DTL);
			int largestId = -1;
			try {
				largestId = Integer.parseInt(CommonUtil.getNextSequence(rows, "dtlLineNo"));
			} catch (InvocationTargetException e) {
				largestId = 1;
			} catch (NoSuchMethodException e) {
				largestId = 1;
			} catch (IllegalAccessException e) {
				largestId = 1;
			}
			
			AccessRightDtlRow rowToAdd = new AccessRightDtlRow();
			form.setCurrIdx(TAB_IDX_DTL);
			rowToAdd.setCompanyCode(form.getCompanyCode());
			rowToAdd.setUserGroupCode(form.getUserGroupCode());
			rowToAdd.setDtlLineNo(String.valueOf(largestId));
			rowToAdd.setModeCreate();
			rowToAdd.setTs(new AccessRightDtlSchema());
			rowToAdd.setIsDelete("");
			rowToAdd.setDtlStatus(ProjectConstants.GENERIC_ACTIVE);
			form.addRow(rowToAdd);

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}

	protected ActionForward processActionDelDetail(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try{
			ArrayList rows = form.getMultiRows(TAB_IDX_DTL);
			int idx = Integer.parseInt(form.getPageEventSrc());
			AccessRightDtlRow rowToEdit = (AccessRightDtlRow) rows.get(idx);
			rowToEdit.setIsDelete("checked");
			form.setRow(idx, rowToEdit);
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}

	////////////////////////////////////////////////////////////////////////////////
	// END OF LOGICAL AND BUSINESS METHODS
	////////////////////////////////////////////////////////////////////////////////


	////////////////////////////////////////////////////////////////////////////////
	// OVERRIDES PARENT'S OPTIONAL METHODS
	////////////////////////////////////////////////////////////////////////////////

	protected void initAction(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		super.initAction(mapping, formIn, request, response, errors);

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
//			HashMap errMsgMap = WebUtil.getModuleErrorMessages(editingUser.getCompanyCode(),
//				DBMENU_GENERAL_MENU, form.getModuleName(), form.getSysLangCode(), DBMENU_OBJECT_TYPE_ERR_MSG);
//			form.setErrMsgMap(errMsgMap);

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void initForm(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		super.initForm(mapping, formIn, request, response, errors);

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void initPage(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		super.initPage(mapping, formIn, request, response, errors);

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeCreate(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
			form.setCompanyCode(WebUtil.getAppropriateCompanyCode(session, ProjectConstants.SP_SHARE_ACCESS_RIGHT));			
			form.setTs(new AccessRightHdrSchema());
			form.setTsName("com.erp.app.admin.accessRight.schema.AccessRightHdrSchema");
			form.setStatus(ProjectConstants.GENERIC_ACTIVE);
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeSave(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void afterSave(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeEdit(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void afterEdit(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeDelete(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void afterDelete(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeRefresh(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void afterRefresh(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	public String getSessionMaintStatus() {

		return getSessionSimpleMaintStatus();
	}

	public String getSessionMaintPk() {

		return getSessionSimpleMaintPk();
	}

	public String getStrutsId() {

		return getFunctionId();
	}

	public String getSimpleFormReadOnlySessionName(){

		return ProjectConstants.SESSION_ACCESS_RIGHT_FORM_READ_ONLY_SESSION_NAME;
	}

	public String getSimpleFormReadOnlyCallerSessionName(){

		return ProjectConstants.SESSION_ACCESS_RIGHT_FORM_READ_ONLY_CALLER_SESSION_NAME;
	}

	protected String getSimpleSrchMenuId() {

		return ProjectConstants.MOD_ACCESS_RIGHT;
	}

	////////////////////////////////////////////////////////////////////////////////
	// END OF OPTIONAL METHODS
	////////////////////////////////////////////////////////////////////////////////


	////////////////////////////////////////////////////////////////////////////////
	// IMPLEMENTS PARENT'S ABSTRACT METHODS
	////////////////////////////////////////////////////////////////////////////////

	protected String getModuleName(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request,HttpServletResponse response) {

		//TODO: Add the following line to ProjectMenuConstants.java
		//public static final String MOD_ACCESS_RIGHT = "MOD_ACCESS_RIGHT";
		return ProjectConstants.MOD_ACCESS_RIGHT;
	}

	protected String getFunctionId() {

		//struts-config xxxxx.do
		return "accessRightMaintenance.do";
	}

	protected Class getMasterFormClass() {

		//the corresponding form class
		return AccessRightMaintenanceForm.class;
	}

	protected Class getMasterVOClass() {

		//corresponding master vo class
		return AccessRightHdrVo.class;
	}

	protected String getMasterFormSessionName() {

		return "accessRightMaintenanceForm";
	}

	protected Class[] getChildRowClass() {

		Class[] childRowClass = new Class[1];

		childRowClass[0] = com.erp.app.admin.accessRight.web.AccessRightDtlRow.class;

		return childRowClass;
	}

	protected String[] getFolderChildIdxMapping() {

		String[] folderChildIdx = new String[2];

		folderChildIdx[0] = String.valueOf(TAB_IDX_DTL);
		folderChildIdx[1] = String.valueOf(TAB_IDX_DTL);

		return folderChildIdx;
	}

	protected SimpleBasePk getPk(ActionForm formIn, HttpServletRequest request) {

		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		AccessRightHdrPk pk = null;
		HttpSession session = request.getSession(false);

		String companyCode = WebUtil.getAppropriateCompanyCode(session, ProjectConstants.SP_SHARE_ACCESS_RIGHT);

		pk = new AccessRightHdrPk(companyCode, form.getUserGroupCode());
		return pk;
	}

	protected void setFormType(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
		HttpServletResponse response, ActionErrors errors){

		AccessRightMaintenanceForm form = (AccessRightMaintenanceForm) formIn;
		form.setFormType(ProjectConstants.FORM_TYPE_MAINT);
	}

	 protected void afterExecuteAction(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) {
	        ((AccessRightMaintenanceForm)formIn).setCompanyCode(WebUtil.getAppropriateCompanyCode(request.getSession(false),ProjectConstants.SP_SHARE_ACCESS_RIGHT ));
	 }
	
	////////////////////////////////////////////////////////////////////////////////
	// END OF ABSTRACT METHODS
	////////////////////////////////////////////////////////////////////////////////
}
